<%@ taglib prefix="nls" uri="http://www.vacoor.com/el/nls/functions" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/view/include/taglibs.jspf" %>
<%--
  ~ Copyright (c) 2005, 2014 vacoor
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  --%>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="${ctx}/css/admin.css"/>
</head>
<body>
<c:set var="lang" value="${empty param.lang ? 'ja': param.lang}"/>
<div class="formHeader">
    <span class="title">${nls:t('网站信息配置')}</span>
    <a href="javascript:location.reload();" class="reload">${nls:t('刷新')}</a>
</div>
<div class="toolbarTab">
    <ul id="tabs">
        <c:forEach var="vars" varStatus="st" items="${grouped}">
            <c:set var="last" value="${st.count}" />
            <li id="tabs_title${st.index}" onclick="tabs('tabs',this);" class="${st.first ? 'on' : ''}">
                <a href="javascript:;">${empty vars.key ? 'Unnamed' : vars.key}</a>
            </li>
            <li class="line">-</li>
        </c:forEach>
        <li id="tabs_title${last}" onclick="tabs('tabs',this);" class=""><a href="javascript:;">增加新变量</a></li>
    </ul>
</div>
<form name="form_cfg_var" method="post" action="save">
    <c:forEach var="vars" varStatus="st" items="${grouped}">
    <div class="" id="tabs_content${st.index}" style="${not st.first ? 'display:none;' : ''}">
        <!--使用DIV兼容chrome firefox等浏览器-->
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTable">
            <tbody>
            <c:forEach var="var" items="${vars.value}">
            <tr>
                <td width="25%" height="40" align="right">${var.desc}：</td>
                <td width="40%">
                    <c:choose>
                        <c:when test="${var.type == 'bool'}">
                        <input type="radio" name="cfg_${var.name}" id="cfg_${var.name}" value="Y"> 是 &nbsp;<input type="radio" name="cfg_${var.name}" id="cfg_${var.name}" value="N" checked="checked"> 否
                        </c:when>
                        <c:when test="${var.type == 'bstring'}">
                        <textarea name="cfg_${var.name}" id="cfg_${var.name}" class="textarea" style="margin:7px 0;"></textarea>
                        </c:when>
                        <c:otherwise>
                            <input type="text" name="cfg_${var.name}" id="cfg_${var.name}" value="${var.value}" class="input">
                        </c:otherwise>
                    </c:choose>
                </td>
                <td width="35%"><span class="siteSetTag">$cfg_${var.name}</span></td>
            </tr>
            </c:forEach>
            <tr class="nb">
                <td width="25%" height="40" align="right">&nbsp;</td>
                <td width="40%">多站点状态下各站只区分基本信息，其他设置多站共享</td>
                <td width="35%">&nbsp;</td>
            </tr>
            <tr class="nb">
                <td colspan="3">
                    <div class="formSubBtn">
                        <input type="submit" class="submit" value="提交">
                        <input type="button" class="back" value="返回" onclick="history.go(-1);">
                        <input type="hidden" name="action" id="action" value="update">
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    </c:forEach>
</form>
<form name="form_addvarname" method="post" action="create">
    <div class="undis" id="tabs_content${last}" style="display: none;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTable">
            <tbody><tr>
                <td width="25%" height="40" align="right">变量名称：</td>
                <td width="75%">
                    <input type="text" name="name" id="varname" value="" class="input">
                    <span class="maroon">*</span><span class="cnote">系统会自动为变量添加 '$cfg_' 前缀</span>
                </td>
            </tr>
            <tr>
                <td height="40" align="right">参数说明：</td>
                <td><input type="text" name="desc" id="varinfo" value="" class="input">
                    <span class="maroon">*</span></td>
            </tr>
            <tr>
                <td height="40" align="right">变量值：</td>
                <td><input type="text" name="value" id="varvalue" value="" class="input"></td>
            </tr>
            <tr>
                <td height="40" align="right">变量类型：</td>
                <td><input type="radio" name="type" value="string" checked="checked">
                    文本&nbsp;
                    <input type="radio" name="type" value="number">
                    数字&nbsp;
                    <input type="radio" name="type" value="bool">
                    布尔(Y/N)&nbsp;
                    <input type="radio" name="type" value="bstring">
                    多行文本 </td>
            </tr>
            <tr class="nb">
                <td height="40" align="right">所属组：</td>
                <td><select name="group"><option value="0">基本设置</option><option value="1">附件设置</option><option value="2">性能设置</option><option value="3">URL静态化</option><option value="4">核心设置</option></select></td>
            </tr>
            <tr class="nb">
                <td colspan="2"><div class="formSubBtn">
                    <input type="submit" class="submit" value="提交">
                    <input type="button" class="back" value="返回" onclick="history.go(-1);">
                    <input type="hidden" name="action" id="action" value="add">
                </div></td>
            </tr>
            </tbody></table>
    </div>
</form>
<script type="text/javascript" src="${ctx}/js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
    function tabs(tabobj, obj)
    {
        $("#"+tabobj+" li[id^="+tabobj+"]").each(function(i){
            if(tabobj+"_title"+i == obj.id)
            {
                $("#"+tabobj+"_title"+i).attr("class","on");
                $("#"+tabobj+"_content"+i).show();
            }
            else
            {
                $("#"+tabobj+"_title"+i).attr("class","");
                $("#"+tabobj+"_content"+i).hide();
            }
        });
    }

</script>
</body>
</html>
